<h3>Sản phẩm tìm thấy</h3>
<?php
	
		if(isset($_POST['tkhoa']) )
		$tkhoa = $_POST['tkhoa'];
		if( isset($_GET['tkhoa']))
		$tkhoa = $_GET['tkhoa'];
		if(isset($_POST['loai'])) 
		$loai  = $_POST['loai'];
		if(isset($_GET['loai']))
		$loai  = $_GET['loai'];
		$sanpham = new sanphambs();
		$sanpham->key = $tkhoa;
		if($loai == 0)
		$sanpham->loai = 0;
		else if($loai == 1)
		$sanpham->loai = 1;
		else if($loai == 2)
		$sanpham->loai = 2;
		else if($loai == 3)
		$sanpham->loai = 3;
		
		$dssanpham = $sanpham->Find();
		$tongsodong = count($dssanpham);
		if($tongsodong > 0)
		{
			if(!isset($_GET['start']))
				$start = 0;
			else
				$start = $_GET['start'];
			
			$limit = 5;
			$next = $start + $limit;
			$back = $start - $limit;
			$danhsach = $sanpham->DS_Find($start, $limit);
			for($i = 0; $i < ($danhsach == false ? 0 : count($danhsach)) ; $i++)
			{
				if($danhsach[$i]['SoLuong']>0)
				{
					echo " <div id='SanPham'> ";
						$hinhanh = new hinhanhbs();
						$hinhanh->MaSanPham = $danhsach[$i]['MaSanPham'];
						$dshinh = $hinhanh->GetList();
						echo "<a href='san-pham-chi-tiet-{$danhsach[$i]['MaSanPham']}'><img src='{$dshinh[0]['patch']}' data-tooltip='$i' /> </a>";
						echo "<p class='TenSanPham'>{$danhsach[$i]['TenSanPham']}</p>";
						echo "<p>Nhà sản xuất: {$danhsach[$i]['TenNhaSX']}</p>";
						echo "<p>Giá bán: <span class='GiaBan'>" . number_format($danhsach[$i]['DonGia']) . " VNĐ</span></p>";
						echo "<p class='DatMua'><a href='index.php?do=giohang&id={$danhsach[$i]['MaSanPham']}'>Đặt mua</a></p>";
				echo "</div>";
				}
			}	
			echo "<div id='mystickytooltip' class='stickytooltip'>";
				for($i = 0; $i < ($danhsach == false ? 0 : count($danhsach)) ; $i++)
				{
					$hinhanh = new hinhanhbs();
					$hinhanh->MaSanPham = $danhsach[$i]['MaSanPham'];
					$dshinh = $hinhanh->GetList();
					echo "<div id='$i' class='atip'>";
							echo "<img src='".$dshinh[0]['patch']."' width='100%' height='270px' />";
							echo "<table class='toolTip' >";
							echo "<tr  > <td   class = 'titleTip' > Xuất xứ : </td> <td> {$danhsach[$i]['TenNhaSX']} </td> </tr>";
							echo "<tr  > <td   class = 'titleTip' > Loại sản phẩm: </td> <td>{$danhsach[$i]['TenLoai']} </td> </tr>";
							echo "<tr  > <td   class = 'titleTip' > Nhóm hàng : </td> <td>{$danhsach[$i]['TenNhomHang']} </td> </tr>";
							
							echo "<tr><td  class = 'titleTip' > Giá bán : </td> <td style='color:#ff0000;'  class = 'titleTip' >" . number_format($danhsach[$i]['DonGia']) . " VNĐ</td></tr>";
							echo "</table>";
						echo "</div>";  
				}
			echo " </div>";
			}
	
?>
<?php
		if($tongsodong > $limit)
		{
			echo "<div id='PhanTrang' align = 'center'>";
				if($start > 0)
					echo "<a href='index.php?do=home_timkiem&loai=$loai&tkhoa=$tkhoa&start=$back'>Trang trước</a>&nbsp;";
				
				$j = 1;
				for($i = 0; $i < $tongsodong; $i += $limit)
				{
					if($i == $start)
						echo "<span style='color:#ff0000;font-weight:bold;'>" . $j . "</span>&nbsp;";
					else
						echo "<a href='index.php?do=home_timkiem&loai=$loai&tkhoa=$tkhoa&start=$i'>" . $j . "</a>&nbsp;";
					
					$j++;
				}
				
				if($start + $limit < $tongsodong)
					echo "<a href='index.php?do=home_timkiem&loai=$loai&tkhoa=$tkhoa&start=$next'>Trang sau</a>";
			echo "</div>";
			echo "<br/>";
		}
?>